Repository navigation
frontend: /metrics with request gauges and token counters - #12
100menotu001 wants to merge 5 commits into
Conversation
GET /metrics (unauthenticated like /health) exports, in Prometheus text format: requests_running / requests_waiting from the admission gate, and monotonic generation, prompt and cached-prompt token totals plus a time-to-first-token sum/count. The names use the tensorfold: prefix so existing dashboards and schedulers that read that engine's series work unchanged.
|
Useful PR — we're in exactly the position it describes. We run dsfront on four GB10 Sparks (switchless ConnectX-7 ring, TP=4, DeepSeek-V4.1-Flash-1017, Two points from the consuming side: 1. Please keep the 2. One semantic detail on the counters, because it decides whether the derived rates are right. sparkDash computes computed-prefill as A slot/queue gauge beyond Right now the dashboard classifies |
…otal sparkDash derives the prefill rate as prompt_tokens_total minus prompt_tokens_cached_total, and clamps the cached delta to the same scrape's prompt delta. That only comes out right if the cached counter counts reused prompt tokens that are already inside the prompt total, rather than an extra series alongside it. That is what the engine reports (Done::cached_tokens is the reused prefix length, and the front end already adds the full prompt length to the prompt total), but nothing in the code said so and nothing stopped an engine from reporting a longer reuse than the prompt it was handed. Document the invariant where the counters live and clamp the cached value at the update site, so a bad reuse length can no longer make the derived prefill rate go negative or inflate it by the cache share.
|
Thanks — both points are now explicit rather than incidental. 1. The 2. That was true before but only by convention, so No slot/queue gauge added — Branch is at |
|
Tested against the four-Spark ring, and it holds. Reporting the numbers because this is the case you asked about — a cache-heavy agent lane where the subset relation is load-bearing. Setup: dsfront built from Consistency check against the engine's own request log. The front end writes one line per served request (
Exact match, and
Counters resetting on restart is visible and matches the PR description: they began at zero when the front end came up. One thing you may want to know from the consumer side: the front end is also the place the session/prefix-cache state lives, so after a restart the counters and the cache both start clean — which means a scraper cannot mistake the reset for a traffic drop as long as the counter values only ever decrease to zero together. Worth a line in the docs if you document the endpoint. We are keeping this build on the production front end for now (one env line, |
…relation, and the restart reset The endpoint shipped undocumented. A consumer testing f36af01 against a four-Spark ring reconciled the counters against the request log (exact match, cached < prompt) and asked for one thing from the docs: that a restart's reset be stated, since the front end is also where the session and prefix-cache state lives, so a scraper should not read the drop to zero as a traffic drop. Lists the six series with their types, spells out that prompt_tokens_cached_total is a subset of prompt_tokens_total (prefill is the difference, and a partition would inflate it by the cache share), notes that generation_tokens_total advances during decode while the prompt, cached and TTFT series land at completion, and states that the counters reset to zero together on a restart.
|
Good — exact reconciliation against the request log is the check that matters, and 758 prefilled of 477,029 is the shape we wanted. The reset is now documented rather than folklore: Docs only; no code change, so the build you tested is unchanged apart from that file. SparkDash#401 is yours to close when you're ready to scrape. |
|
Docs commit noted — On the dashboard side: MiaAI-Lab/sparkDash#401 is now a PR rather than an issue — MiaAI-Lab/sparkDash#411 wires the |
…ill_seconds The front end already receives Done.prefill_us (prefill started -> first token) and dropped it. sparkDash needs a prefill timing source to report prefill tok/s, and TTFT is not one: it is measured from the front end and also covers the gate and the submit round trip, so dividing by it understates the rate. Add the summary over completed requests, so the rate is d(prompt - cached) / d(request_prefill_seconds_sum) -- the computed tokens over the time the engine spent computing them. Recorded where the prompt, cached and TTFT counters are recorded, so one window's deltas cover the same requests. The exposition moves into metrics_body() and a test checks every series is present and every sample is a number. Measured on the mock engine (--prefill-tps 2000, 426-token prompt): first request 426 computed in 0.2156 s, second with 425 cached 1 computed, window 427 tokens / 0.2177 s = 1962 tok/s against the 2000 configured.
|
The timing source was already on the wire and the front end was dropping it: It is on Why TTFT could not stand in: it is measured from the front end from the moment the request is accepted, so it includes the gate wait and the submit round trip and is always at least Recorded once per completed request, at the same site as the prompt/cached/TTFT counters, so one window's deltas cover the same requests; If you rebuild the front end from |
|
Built Cold, uncached prefill. A unique 20,481-token prompt ( That lands on our independent baseline for this ring (8.1k–9.0k tok/s at 8k/32k context, measured with a separate harness before any of this existed), which is the cross-check I wanted: the new series is measuring the same thing the engine actually does, not a plausible-looking number. The cache-heavy case you flagged. Same 20,481-token prompt sent again, fully cached this time ( The subset relation holds ( Consumer side, for completeness. With One small thing worth documenting if you touch |
The restart paragraph said the counters and the session/prefix-cache state zero together, which covers what a scraper reads but not what it remembers: a baseline held across the restart still divides the new prefill sum by an old reference point, so the first window after a restart reads one absurd rate before the series line up again. States the rule the consumer arrived at on their own (they discard the first post-restart window) so the next person does not rediscover it. Docs only.
|
Added in Docs only — nothing on the wire changed, so |
pico-dgx-ds4's dsfront can serve GET /metrics with tensorfold:-prefixed counters (Picom-code/pico-dgx-ds4#12): request gauges, generation/prompt/ cached token totals and a TTFT summary. That is the series set the TensorFold reader already parses, so the pico branch now reads it instead of always forcing generationTps = 0. When the scrape yields a counter diff the decode rate is labelled "window"; otherwise the dashboard-stream rate and the synthetic sample keep working unchanged, so a build without /metrics is unaffected. Counters are cleared before the scrape so a rate left by the previous poll's sample is never mistaken for a counter-derived one. (cherry picked from commit 8af80be)
The endpoint, its series, the exposition's tests and the operations.md section are 100menotu001's work, contributed as Picom-code#12. This branch carried them over unchanged, but the commit that did so said only "ported from Picom-code#12" in its body -- nothing in the tree said whose work it was, so a reader of CHANGES.md, operations.md or server.rs would take it for this fork's. Says so in all four places a reader looks: the CHANGES.md section header and its opening paragraph, the operations.md section, the doc comments on the counters and metrics_body(), and the deploy README's PR table and fork-work table. No code changes: the front end's 63 tests still pass. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Adds
GET /metricstodsfront(Prometheus text, open like/health). Today the front end exposes no load or token counters, so external dashboards and schedulers can't tell how busy the engine is.Exported:
requests_running,requests_waiting— from the admission gategeneration_tokens_total,prompt_tokens_total,prompt_tokens_cached_total— monotonictime_to_first_token_seconds_sum/_countI used the
tensorfold:prefix so tools that already scrape that engine's series (dashboards, schedulers) read this one unchanged. Happy to rename to adsgb10_prefix if you'd rather keep the namespace separate; it's a one-line change per series.Notes:
cargo build --release, and running on a 4-node TP4 setup (16 slots) against live traffic.